<script>
function reSentEmail(){
	$.post('<?php echo CHtml::normalizeUrl(array('/site/reSentEmail'));?>',{'uid':'<?=$model->uid?>','email':'<?=$model->email?>'}, function (data) {
        var ret = $.parseJSON(data);
        if (ret != null && ret.success != null && ret.success) {
			alert(ret.msg);
        }
	});
}
</script>
<?php
$this->widget('webroot.admin.protected.extensions.fancybox.EFancyBox', array('target' => '.fan', 'config' => array('width' => 620, 'height' => 360,'type'=>'iframe','hideOnOverlayClick'=>false)));
$this->widget('webroot.admin.protected.extensions.fancybox.EFancyBox', array('target' => '.tx', 'config' => array('width' => 520, 'height' => 180,'type'=>'iframe','hideOnOverlayClick'=>false,'onClosed'=>'js:function(){window.location.href="'.Yii::app()->createUrl("site/userinfo").'";}')));
?>

<div id="contener" _height="auto">
	<?php $this->beginWidget('application.widget.site.userLeftWidget'); ?>
	<?php $this->endWidget(); ?>
	<div class="main2">
		<?php $this->beginWidget('application.widget.site.newWidget'); ?>
		<?php $this->endWidget(); ?>
		<div class="right_mainBox">
			<div class="mainMenu"><img src="images/title09.png" width="726" height="23" alt="活動參與紀錄" title="活動參與紀錄" />
			<?php
			if($rowTable){
				foreach($rowTable as $row){
					if($row->status==4){
						$condition = new CDbCriteria();
						$condition->with = 'user';
						$condition->addCondition('t.activityid='.$row->activityid);
						$condition->addCondition('t.win=1');
						$winners = Record::model()->findAll($condition);
						unset($condition);
						$codeArr = array();
						$userArr = array();
						if($winners){
							foreach($winners as $record){
								$codeArr[] = $record->code;
								$userArr[] = $record->user->username;
							}
						}
					}
					switch($row->status){
						case 1:
							$status = '未開始';
							break;
						case 2:
							$status = '已開始';
							break;
						case 3:
							$status = '已結束';
							break;
						case 4:
							$status = '已結束';
							break;
						default:
							$status = '已結束';
					}					
					$condition = new CDbCriteria();
					$condition->addCondition('activityid='.$row->activityid);
					$condition->addCondition('uid='.Yii::app()->user->id);
					$times = Record::model()->count($condition);
					unset($condition);
					
			?>
				<div class="memberBOX1">
					<table width="720" border="0" align="center" cellpadding="0" cellspacing="3">
						<tr>
							<td height="30" colspan="3" align="center" valign="middle" background="images/bg3.gif">活動訊息</td>
							<td width="148" align="center" valign="middle" background="images/bg3.gif">開獎資訊/中獎人</td>
							<td width="80" align="center" valign="middle" background="images/bg3.gif">狀態</td>
						</tr>
						<tr>
							<td width="160" align="center" valign="middle">
								<div class="memberBOX1_img"><a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>"><img src="<?=Yii::app()->params['prizePath']?>/<?=$row->prize->pic?>" width="320" height="240" /></a></div>
							</td>
							<td width="360" align="left" valign="top">
								<ul>
									<li>活動ID：<a href="<?=Yii::app()->createUrl('activity/detail',array('id'=>$row->activityid))?>"><?=$row->serial?></a></li>
									<li>活動類別：<span class="green"><a href="<?=Yii::app()->createUrl('activity/index',array('class'=>$row->class))?>" title="<?=$row->class?>" target="_self"><?=$row->class?></a></span></li>
									<li>商品資訊：<br />
										<span class="Orange"><?=$row->prize->prizename?></span><br />
										<?=Helper::truncate_utf8_string($row->prize->description,50)?></li>
								</ul>
							</td>
							<td width="250" align="left" valign="top">
								<?php
								if($row->status<3){
								?>
								<ul>
									<li>可參加次數：<span class="red1"><a href="#"><?=$row->times-$times?></a></span></li>
									<li>參與人數：<?=count($row->records)?>/<?=$row->people?></li>
									<li>活動資訊：<br />
										<?=$row->new?></li>
								</ul>
								<?php
								}
								?>
							</td>
							<td align="center" valign="middle" bgcolor="#E1E1E1">
								<?php
								if($row->status==4){
								?>
								<p class="blue"><a class="fan" href="<?=Yii::app()->createUrl('activity/record',array('id'=>$row->activityid,'win'=>1))?>" title="中獎號碼明細">中獎號碼明細</a></p>
								<?php
								}
								?>
								<p class="blue"><a class="fan" href="<?=Yii::app()->createUrl('activity/record',array('id'=>$row->activityid))?>" title="抽獎號碼明細">抽獎號碼明細</a></p>
							</td>
							<td align="center" valign="middle" bgcolor="#E1E1E1"><?=$status?></td>
						</tr>
					</table>
				</div>
			<?php
				}
			}
			?>
				<div id="pager" align="center" style="margin:10px 0;">
				<?php  
				$this->widget('CLinkPager',array(  
					'header'=>'',  
					'firstPageLabel' => '<<',
					'lastPageLabel' => '>>',
					'prevPageLabel' => '<',
					'nextPageLabel' => '>',
					'pages' => $pages,  
					'maxButtonCount'=>13  
					));  
				?>
				</div>				
			</div>
			<div class="mainContentBox"> </div>
			<div class="right_mainBox_bottom"></div>
		</div>
	</div>
</div>
